<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%> 
	<link rel="stylesheet" type="text/css" media="screen" href="/css/ui.jqgrid.css" />
	<link href="/css/ddaccordion.css" rel="stylesheet" type="text/css" media="screen" />
	<!-- 数字验证 -->
	<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>	
	<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
	<script src="/js/grid.locale-en.js" type="text/javascript"></script>
	<script src="/js/jquery.jqGrid.min.js" type="text/javascript" charset="UTF-8"></script>
	<script src="/js/ckeditor/ckeditor.js" type="text/javascript"></script>
	<s:url var="supplierPops" value="/json/supplierPops.do"/>
	<s:url var="brandPops" value="/json/brandPops.do"/>
	<style type="text/css" media="screen">
	<!-- 
		SELECT.selCont{ margin: 10px; width: 200px; }
    div.jHtmlArea { border: solid 1px #ccc; }
  -->
  </style>
	<style type="text/css">
	.msg{float:left; line-height:1em; margin:0; display:block;border:1px solid #f66;padding:2px 5px;*padding:2px 5px 1px;}
	.msg.rn{background-color:#fff2f2;border-color:#f66;}
	</style>
	<s:if test="hasActionErrors()">
		<p><span class="msg rn"><s:actionerror/></span></p>
	</s:if>
	<s:if test="hasActionMessages()">
		<p><span class="msg rn"><s:actionmessage/></span></p>
	</s:if>  
	<script type="text/javascript"> 
	 var content;
	 var qry_target = '01';
	 $(function() {
		 	<c-rt:if test="${proposeProduct.supplierId eq '010000' or proposeProduct.supplierId eq '010001'}">
	 			$("#twSupplier").show();
	 			<c-rt:if test="${not empty proposeProduct.twSupplierId}">
	 				$("#getTwSupplier").hide();
	 			</c-rt:if>
		 	</c-rt:if>
		 	//BO及SCM商品才可开立预购和订制卖场
		 	<c-rt:choose>
				<c-rt:when test="${(proposeProduct.type eq '0' or proposeProduct.type eq '1') and not empty proposeProduct.isScm and proposeProduct.isScm ne 'N' }">
					$("#showUseDeliveryDay").show();
				</c-rt:when>
				<c-rt:otherwise>
					$("#showUseDeliveryDay").hide();
				</c-rt:otherwise>
			</c-rt:choose>
			$('input[name=useDeliveryDay]').each(function(){
				 $(this).click(function(){
					 if ( $(this).val() == "Y" ){
				 	 		$("#showDeliveryDayTh").show();
				 	 		$("#showDeliveryDayTd").show();
				 	 }else{
				 		$("#showDeliveryDayTh").hide();
			 	 		$("#showDeliveryDayTd").hide();
				 	 }
					 $("#deliveryDay").val("0");
				 });
			 });		 
			$("#getSupplier").click(function() {
				$("#spId").val("");
				$("#spName").val("");
				doAR('${supplierPops}', 'dialog'); 
				openDialog('供应商搜寻',content, 550, 440);
			});	 
			$("#getTwSupplier").click(function() {
				$("#spId").val("twSupplierIdParam");
				$("#spName").val("twSupplierCompanyName");
				doAR('${supplierPops}', 'dialog'); 
				openDialog('供应商搜寻',content, 550, 440);
			});
			$("#getBrand").click(function() {
				doAR('${brandPops}', 'dialog'); 
				openDialog('品牌搜寻',content, 550, 440);
			});	
		 $("#loadingImg").dialog({
			  title: '资料载入中',
				bgiframe: true,
				autoOpen: false,
				height: 150,
				width:280,
				modal: true
		 });
		 $("#length").blur(function(){
			 calcVolume();
		 });
		 
		 $("#width").blur(function(){
			 calcVolume();
		 });

		 $("#height").blur(function(){
			 calcVolume();
		 });
		 $("#supplierIdParam").numeric();
		 $("#cost").numeric({allow:"."});
		 $("#price").numeric({allow:"."});
		 $("#proposeShelfPrice").numeric({allow:"."});
		 $("#jTaxClass").numeric({allow:"."});
		 $("#jLeadTime").numeric();
		 $("#length").numeric();
		 $("#width").numeric();
		 $("#height").numeric();
		 $("#minpo").numeric();
		 $("#maxpo").numeric();		
		 $("#weight").numeric();
		 $("#volume").numeric();
		 $("#deliveryDay").numeric();

		//load default value
		$("input[name=isScm]").each(function(){
			 $(this).click(function(){
				 initType($(this).val());
			 });
	 	});

		<c-rt:if test="${not empty proposeProduct.id}">
			initType("${proposeProduct.isScm}");
 			initDeliveryDay("${proposeProduct.isScm}","${proposeProduct.type}");
 			<c-rt:if test="${not empty proposeProduct.type}">
 				$("input[name=type][type=radio]").eq("${proposeProduct.type}").attr("checked", true);
 			</c-rt:if>
 			<c-rt:if test="${proposeProduct.useDeliveryDay eq 'Y'}">
 				$("input[name=useDeliveryDay][type=radio]").eq(0).attr("checked", true);
	  		$("#showDeliveryDayTh").show();
				$("#showDeliveryDayTd").show();
				$("#deliveryDay").val("${proposeProduct.deliveryDay}");
			</c-rt:if>
 		</c-rt:if>
 	
	 	$("input[name=type]").each(function(){
		 $(this).click(function(){
			 	initDeliveryDay($('input[name=isScm]:radio:checked').val(),$(this).val());
		 });
	 	});	 	

		 
			if ( "" != $("#tempCategoryPath").val()){ 
				calcVolume();
				var tempId = $("#tempCategoryPath").val().split("/");
				if ( $("#orderNotice").val() == "" )
					$.post("${midContextPath}/product/loadOrderNotice.do",{categoryId:tempId[0]},orderNoticeCallback,"json");
				$("#categorySelect").val(tempId[0]).attr("selected","selected");
				$("#mainCategoryId").val(tempId[tempId.length -1]);
				$.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[0]},elementSelectCallback,"json");
			}
			//第0层
			$("#categorySelect").click(function(){
				if ( null != $(this).val()  ){
					$.post("${midContextPath}/product/loadOrderNotice.do",{categoryId:$(this).val()},orderNoticeCallback,"json");
					$.ajax({
					    url: '${midContextPath}/category/getProductCategory.do',
					    type: 'post',
					    dataType: 'json',
					    data: {categoryid:$(this).val(), callback: 'elementSelectCallback'},
					    cache: false,
					    beforeSend: function(xhr) {
								$("#loadingImg").dialog("open");
								$('#elementSelect').find('option').remove().end();
						 		$('#attributeSelect').find('option').remove().end();
						 		$('#itemSelect').find('option').remove().end();
						 		$('#unitSelect').find('option').remove().end();
						 		$('#listSelect').find('option').remove().end();					
					    },
					    success: function( strData ){
					    	$("#loadingImg").dialog("close");
					    	elementSelectCallback(strData);
						}
					});
				}
				$("#mainCategoryId").val($(this).val());
				$("#tempCategoryPath").val("");
			});
			//第1层
			$("#elementSelect").click(function(){
				if ( null != $(this).val()  ){
					$.ajax({
					    url: '${midContextPath}/category/getProductCategory.do',
					    type: 'post',
					    dataType: 'json',
					    data: {categoryid:$(this).val(), callback: 'attributeSelectCallback'},
					    cache: false,
					    beforeSend: function(xhr) {
								$("#loadingImg").dialog("open");
								$('#attributeSelect').find('option').remove().end();
							  $('#itemSelect').find('option').remove().end();
							  $('#unitSelect').find('option').remove().end();
							  $('#listSelect').find('option').remove().end();						
					    },
					    success: function( strData ){
					    	$("#loadingImg").dialog("close");
					    	attributeSelectCallback(strData);
						}
					});	  
					$("#mainCategoryId").val($(this).val());
					$("#tempCategoryPath").val("");
				}
			});
			//第2层
			$("#attributeSelect").click(function(){
				if ( null != $(this).val()  ){
					$.ajax({
					    url: '${midContextPath}/category/getProductCategory.do',
					    type: 'post',
					    dataType: 'json',
					    data: {categoryid:$(this).val(), callback: 'itemSelectCallback'},
					    cache: false,
					    beforeSend: function(xhr) {
								$("#loadingImg").dialog("open");
							  $('#itemSelect').find('option').remove().end();
							  $('#unitSelect').find('option').remove().end();
							  $('#listSelect').find('option').remove().end();
					    },
					    success: function( strData ){
					    	$("#loadingImg").dialog("close");
					    	itemSelectCallback(strData);
						}
					});	  	
					$("#mainCategoryId").val($(this).val());
					$("#tempCategoryPath").val("");
				}
			});
			//第三层
			$("#itemSelect").click(function(){
				if ( null != $(this).val()  ){
					$.ajax({
					    url: '${midContextPath}/category/getProductCategory.do',
					    type: 'post',
					    dataType: 'json',
					    data: {categoryid:$(this).val(), callback: 'unitSelectCallback'},
					    cache: false,
					    beforeSend: function(xhr) {
								$("#loadingImg").dialog("open");
							  $('#unitSelect').find('option').remove().end();
							  $('#listSelect').find('option').remove().end();
					    },
					    success: function( strData ){
					    	$("#loadingImg").dialog("close");
					    	unitSelectCallback(strData);
						}
					});	 	  	
					$("#mainCategoryId").val($(this).val());
					$("#tempCategoryPath").val("");
				}					
			});
			//第四层
			$("#unitSelect").click(function(){
				if ( null != $(this).val()  ){
					$.ajax({
					    url: '${midContextPath}/category/getProductCategory.do',
					    type: 'post',
					    dataType: 'json',
					    data: {categoryid:$(this).val(), callback: 'listSelectCallback'},
					    cache: false,
					    beforeSend: function(xhr) {
								$("#loadingImg").dialog("open");
								$('#listSelect').find('option').remove().end();
					    },
					    success: function( strData ){
					    	$("#loadingImg").dialog("close");
					    	listSelectCallback(strData);
						}
					});	  	
					$("#mainCategoryId").val($(this).val());
					$("#tempCategoryPath").val("");
				}
			});	  
			//第五层
			$("#listSelect").click(function(){
				if ( null != $(this).val()  ){
					$("#mainCategoryId").val($(this).val());
					$("#tempCategoryPath").val("");
					combineCategoryPath();
					checkIsEndNodex();
				}
			});							
		    
			$("input[name='submit']").click(function(){
				var brief_result = true;
				if ($("#name").val() == "" ){
					alert("请输入商品名称");
					$("#name").focus();
					return false;
				}
				if ( $('input[name=isScm]').is(":checked") == false ){
					alert("请选择采购类型");
					return false;
				}				
				if ($('input[name=type]').is(":checked") == false){
					alert("请输入商品型态(一般商品,赠品,配件) ");
					return false;
				}
				if ( $('input[name=isScm]:checked').val() == 'Y' || $('input[name=isScm]:checked').val() == 'B' ){
					if ( $('input[name=useDeliveryDay]:checked').val() == 'Y'){
						if ( $("#deliveryDay").val() == "" || parseInt($("#deliveryDay").val(),10) == 0 ){
							alert("订制商品天数不可为空值且必须大于0天");
							$("#useDeliveryDay").focus();
							return false;
						}
					}
				}				
				if ($('input[name=virtual]').is(":checked") == false){
					alert("请输入是否为虚拟商品");
					return false;
				}

				if ( $("#mainCategory").text() == "" || $('#mainCategory').val()=="0"){
					alert("请输入主目录");
					return false;
				}				 
				if ( $("#mainCategory").text() == "" || $("#isEndNode").val() != "Y" ){
					alert("请选择最底层的目录");
					return false;
				}		
								
				if ($("#cost").val() == "" ){
					alert("请输入商品成本");
					$("#cost").focus();
					return false;
				}
				if ($('input[name=type]:checked').val() != '2' ) {
					if (parseFloat($("#cost").val()) <= 0.00 ){
						alert("非赠品成本必须大于 0.00");
						$("#cost").focus();
						return false;
					}
				} else {
					if (parseFloat($("#cost").val()) < 0.00 ){
						alert("成本否小于 0.00");
						$("#cost").focus();
						return false;
					}
				}
				if ($("#length").val() == "" ){
					alert("请输入长");
					$("#length").focus();
					return false;
				}
				if ($("#width").val() == "" ){
					alert("请输入宽");
					$("#width").focus();
					return false;
				}
				if ($("#height").val() == "" ){
					alert("请输入高");
					$("#height").focus();
					return false;
				}
				if ($("#weight").val() == "" ){
					alert("请输入重量");
					$("#weight").focus();
					return false;
				}
				if ($("#unit").val() == "" ){
					alert("请输入單位");
					$("#unit").focus();
					return false;
				}
				if ($("#price").val() == "" ){
					alert("请输入厂商建议售价(市价)");
					$("#price").focus();
					return false;
				}
				if ($("#editDeliverGeoRange").val() == "" ){
					alert("运送限定区域");
					$("#editDeliverGeoRange").focus();
					return false;
				}
				if ($("#expireManage").val() == "" ){
					alert("效期管理分类");
					$("#expireManage").focus();
					return false;
				}
				if ( $("#supplierIdParam").val() == ""){
					alert("请选择供应商");
					$("#supplierIdParam").focus();
					return false;
				}
				if ( $("#supplierIdParam").val() == "010000" || $("#supplierIdParam").val() == "010001"){
					if (  $("#twSupplierIdParam").val() == "" ) {
						alert("若供应商为万美供应商，台湾供应商为必填");
						$("#twSupplierIdParam").focus();
						return false;
					}
				}
				//if ( $("#brandIdParam").val() == ""){
					//alert("请选择品牌");
					//$("#brandIdParam").focus();
					//return false;
			//	}
				if ( $("#pm").val() == ""){
					alert("请选择主要负责PM");
					$("#pm").focus();
					return false;
				}
				if( $("#brief").val() == ""){
					alert("请输入商品特色");
					return false;
				}else{
				 var xxx = $("#brief").val().length;
				 var k = 0;
				 for(var i = 0 ; i < xxx; i++ ){
					 if ( $("#brief").val().charAt(i) == "\n"){
						 k++;
					 }
				 }
				 if ( k > 4 ){
					 alert("商品特色最多只能输入五行");
					 return false;
				 }
				 if ( k == 0 ){
					 if ( $("#brief").val().length > 30 ){
						 alert("商品特色第1行字数长度 超过30");
						 brief_result = false;
					 }
				 }else{
					 if ( $("#brief").val().indexOf("\n") != -1 ){
						 var briefArray = $("#brief").val().split("\n");
						 var ii = 0;
						 while( brief_result && ii <=briefArray.length-1 && ii < 5) {
							 if ( briefArray[ii].length > 30 ){
								 alert("商品特色第" + (ii+1) + "行字数长度 超过30");
								 brief_result = false;
							 }
							 ii++;
						 }
					 }
				 }
				}			
				if ( brief_result == false) return false;
				if(CKEDITOR.instances.description.getData().length==0){
					alert("请输入商品描述");
					return false;
				}

				if(CKEDITOR.instances.details.getData().length==0){
					alert("请输入規則參數");
					return false;
				}							
			});
	 });
	 
		function initType(obj){
			defultType();
			if ( obj == "N" ) {//PO
				$("#type1").hide();//預購
			}
			$("input[name=type][type='radio']").eq(0).attr("checked", true);
			initDeliveryDay(obj,$('input[name=type]:radio:checked').val());
		}

		function initDeliveryDay(isScm,type){
			defaultDeliveryDay();
			if ( isScm == "B" || isScm == "Y" ){//BO&SCM
				if ( type == "0" || type == "1"){//一般&預購
					$("#showUseDeliveryDay").show();
				  $("input[name=useDeliveryDay][type=radio]").eq(1).attr("checked", true);
				}
			}
		}

		function defultType(){
			$("#type0").show();//一般
			$("#type1").show();//預購
			$("#type2").show();//贈品
			$("#type3").show();//配件
			$("#type7").show();//限定立即购买商品
		}

		//訂制天數預設值
		function defaultDeliveryDay(){
			$("#showUseDeliveryDay").hide();
		  $("input[name=useDeliveryDay][type=radio]").attr("checked",'');
		  $("#deliveryDay").val("0");
			$("#showDeliveryDayTh").hide();
	 	 	$("#showDeliveryDayTd").hide();
		}
	  
		//计算体积
		function calcVolume(){
			$("#volume").val($("#length").val()* $("#width").val()*$("#height").val());
		}	
	 	//购物须知ajax
		function orderNoticeCallback(jsonOrderNotice){
			CKEDITOR.instances.orderNotice.setData(jsonOrderNotice);
		}				

		//判断是否为最底层
	 	function checkIsEndNodex(){
	  	$.post("${midContextPath}/product/getJsonCategoryData.do",{mainCategoryId : $("#mainCategoryId").val()},endNodeCallback,"json");
	 	}	
	 	function endNodeCallback(categoryResult){
	 			$("#isEndNode").val(categoryResult);
	 	}
	 	
		function categoryCallback(fullCategoryPath){
			 $("#mainCategory").html(fullCategoryPath);
		} 
		function elementSelectCallback(categories){
			if ( "" != $("#tempCategoryPath").val()){
				var tempId = $("#tempCategoryPath").val().split("/");
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
					if ( categories[i].id == tempId[1] ){
						$('#elementSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
						$("#isEndNode").val(categories[i].isEndnode);
					}else
						$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
				if ( tempId.length-1 > 1 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[1]},attributeSelectCallback,"json");
			}else{
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
						$("#isEndNode").val(categories[i].isEndnode);
						$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
			}
			combineCategoryPath();
			checkIsEndNodex();
		}
		function attributeSelectCallback(categories){
			if ( "" != $("#tempCategoryPath").val()){
				var tempId = $("#tempCategoryPath").val().split("/");
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
					if ( categories[i].id == tempId[2] ){
						$('#attributeSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
						$("#isEndNode").val(categories[i].isEndnode);
					}else
						$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
				if ( tempId.length-1 > 2 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[2]},itemSelectCallback,"json");
			}else{
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
						$("#isEndNode").val(categories[i].isEndnode);
						$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
			}
			combineCategoryPath();
			checkIsEndNodex();
		}
		function itemSelectCallback(categories){
			if ( "" != $("#tempCategoryPath").val()){
				var tempId = $("#tempCategoryPath").val().split("/");
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
					if ( categories[i].id == tempId[3] ) {
						$('#itemSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
						$("#isEndNode").val(categories[i].isEndnode);
					}else
						$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
				if ( tempId.length-1 > 3 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[3]},unitSelectCallback,"json");
			}else{
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
						$("#isEndNode").val(categories[i].isEndnode);
						$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
			}
			combineCategoryPath();
			checkIsEndNodex();
		}
		function unitSelectCallback(categories){
			$('#listSelect').find('option').remove().end();
			if ( "" != $("#tempCategoryPath").val()){
				var tempId = $("#tempCategoryPath").val().split("/");
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
					if ( categories[i].id == tempId[4] ) {
						$('#unitSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
						$("#isEndNode").val(categories[i].isEndnode);
					}else
						$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
				if ( tempId.length-1 > 4 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[4]},listSelectCallback,"json");
			}else{
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
						$("#isEndNode").val(categories[i].isEndnode);
						$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
			}
			combineCategoryPath();
			checkIsEndNodex();
		}
		function listSelectCallback(categories){
			if ( "" != $("#tempCategoryPath").val()){
				var tempId = $("#tempCategoryPath").val().split("/");
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
					if ( categories[i].id == tempId[5] ) {
						$('#listSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
						$("#isEndNode").val(categories[i].isEndnode);
					}else
						$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
			}else{
				for( var i = 0 ; i < categories.length; i++ ){
					var cmark='';
	        		if(categories[i].isBrand=="Y"){
	        			cmark=cmark+'○';//品牌
	        		}
	        		 if(categories[i].isPromotion=="Y"){
	        			 cmark=cmark+'◎';//活動
	        		}  
						$("#isEndNode").val(categories[i].isEndnode);
						$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
				}
			}
			combineCategoryPath();
			checkIsEndNodex();
		}			
		//组合目录路径
		function combineCategoryPath(){
			var categoryTemp = $('#categorySelect option:selected').text(); 
			var elementTemp =  $('#elementSelect option:selected').text();
			var attributeTemp = $('#attributeSelect option:selected').text();
			var itemTemp = $('#itemSelect option:selected').text();
			var unitTemp = $('#unitSelect option:selected').text();
			var listTemp = $('#listSelect option:selected').text();
			var textTemp ;
			if ( "" != categoryTemp ) textTemp = categoryTemp;
			if ( "" != elementTemp ) textTemp = textTemp + " > " +  elementTemp;
			if ( "" != attributeTemp ) textTemp = textTemp + " > " +  attributeTemp;
			if ( "" != itemTemp ) textTemp = textTemp + " > " +  itemTemp;
			if ( "" != unitTemp ) textTemp = textTemp + " > " +  unitTemp;
			if ( "" != unitTemp ) textTemp = textTemp + " > " +  listTemp;
			$("#mainCategory").html(textTemp);
		} 		
	 </script>	 
	 <script type="text/javascript" charset="UTF-8" src="/js/select-chain.js" charset="UTF-8"></script>
<br/>
<h1>提报商品管理
<div class="f-link">
<a href="edit.do?productId=${productId}" />编辑商品</a>
<a href="spec.do?productId=${productId}" />编修规格</a>
<a href="<%=ServerValue.getMidContextPath()%>/image/editPropose.do?productId=${productId}" />上传图档</a>
<a href="<%=ServerValue.getMidContextPath()%>/proposeProductApprove/list.do">回列表页</a>
</div>
</h1>
<s:form action="save.do" method="post" id="productForm">
<table class="tb-data" width="100%">	
		<tr>
			<th>商品编号</th>			
			<td colspan="3"> 
				<c-rt:choose>
					<c-rt:when test="${empty productId}">系统流水号发放</c-rt:when>
					<c-rt:otherwise>${productId}</c-rt:otherwise>
				</c-rt:choose>
			</td>
		</tr>
		<tr>
			<th>*商品名称</th>			
					<td colspan="3">        
			    <input type="text" name="name" id="name" size="100" value="${proposeProduct.name}"/>
			    <div id="nameTip" style="width:450px;"></div>	        
        </td>
	  </tr>
	  <tr>	
			<th>*采购模式</th>			
			<td colspan="3">     
				<input id="isScmN" name="isScm" type="radio" value="N" <c-rt:if test="${empty proposeProduct.isScm or proposeProduct.isScm eq 'N'}">checked="checked"</c-rt:if>/>入仓
				<input id="isScmB" name="isScm" type="radio" value="B" <c-rt:if test="${proposeProduct.isScm eq 'B'}">checked="checked"</c-rt:if>/>BO
     		<input id="isScmY" name="isScm" type="radio" value="Y" <c-rt:if test="${proposeProduct.isScm eq 'Y'}">checked="checked"</c-rt:if>/>SCM
				<a href="${midContextPath}/images/scm.png" target="_blank">采购模式说明</a>
			</td>
		</tr>	  
		<tr>
			<th >*商品型态 </th>			
			<td colspan="3">
				<c:if test="${proposeProduct.type eq '7'}">
					<span id="type0"><input name="type" type="radio" value="7" <c:if test="${proposeProduct.type eq '7'}">checked="checked"</c:if>/>限定立即购买商品</span>
				</c:if>
				<c:if test="${proposeProduct.type ne '7'}">
	        <span id="type0"><input name="type" type="radio" value="0" <c:if test="${empty proposeProduct.type or proposeProduct.type eq '0'}">checked="checked"</c:if>/>一般商品</span>
	        <c-rt:if test="${product.isScm ne 'N'}">
	        	<span id="type1"><input name="type" type="radio" value="1" <c:if test="${proposeProduct.type eq '1'}">checked="checked"</c:if>/>预购</span>
	        </c-rt:if>
	        <span id="type2"><input name="type" type="radio" value="2" <c:if test="${proposeProduct.type eq '2'}">checked="checked"</c:if>/>赠品</span>
	        <span id="type3"><input name="type" type="radio" value="3" <c:if test="${proposeProduct.type eq '3'}">checked="checked"</c:if>/>配件(加购)</span>
	        <span id="type7"><input name="type" type="radio" value="7"/>限定立即购买商品</span>
        </c:if>
      </td>
	  </tr>
	 	<tr id="showUseDeliveryDay" style="display:none;">
		 	<th>是否使用<br/>"订制商品"?</th>
	 		<td>
				<input name="useDeliveryDay" type="radio" value="Y" <c-rt:if test="${proposeProduct.useDeliveryDay eq 'Y'}">checked="checked"</c-rt:if>/>是
		    <input name="useDeliveryDay" type="radio" value="N" <c-rt:if test="${proposeProduct.useDeliveryDay eq 'N'}">checked="checked"</c-rt:if>/>否
		    <br/><span class="txt-rd">【※请确认出货所需天数（供应商进货+物流理货保守估计约3天），<br/>一旦填入该出货时间会在前台显示】</span>
			</td>
	 		<th id="showDeliveryDayTh" style="display:none;">订制商品天数</th>
	 		<td id="showDeliveryDayTd" style="display:none;">
				<input id="deliveryDay" name="deliveryDay" type="text" value="${proposeProduct.deliveryDay}"/>
		  </td>
	 	</tr>	  
	   <tr>
			<th>建立者<br/>
				建立日期<br/> 
					修改者<br/>
				修改日期
				</th><td colspan="3">
					${proposeProduct.createUser}<br/>
					<fmt-rt:formatDate value="${proposeProduct.createDate}" pattern="yyyy-MM-dd HH:mm:ss" /><br/>
					${proposeProduct.modifyUser}<br/>
				<fmt-rt:formatDate value="${proposeProduct.modifyDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
	  	
	  </tr>
		<tr style="display:none">
			<th>*是否为虚拟商品</th>			
					<td colspan="3"><input id="virtual" name="virtual" type="radio" value="Y"  <c:if test="${proposeProduct.isVirtual eq 'Y'}">checked="checked"</c:if>/>是
                    <input id="virtual" name="virtual" type="radio" value="N"  <c:if test="${proposeProduct.isVirtual eq 'N'}">checked="checked"</c:if>/>否
                    </td>
	  </tr>
		<tr>
			<th>*主分类</th>			
			<td colspan="3">
				<span class="txt-rd">○符号表示该分类为品牌;◎表活動</span><br/>
				<select id="categorySelect" name="categoryid" size="5" class="selCont">
         	<c-rt:forEach items="${rootCategories}" var="category">
						<option value="${category.id}">${category.name}</option>
					</c-rt:forEach>
        </select>       
        <select id="elementSelect" name="categoryid" size="5" class="selCont">            	
        </select>
        <select id="attributeSelect" name="categoryid" size="5" class="selCont">
        </select>
        <br/>
        <select id="itemSelect" name="categoryid" size="5" class="selCont">
        </select>
        <select id="unitSelect" name="categoryid" size="5" class="selCont">
        </select>
        <select id="listSelect" name="categoryid" size="5" class="selCont">
        </select>
        <br/>
                          主分类为：<span id="mainCategory"></span>
			</td>
		</tr>
		<tr>
			<th>*商品成本</th>			
				<td colspan="3"><input id="cost" name="cost" type="text" value="<fmt:formatNumber value="${proposeProduct.cost}" pattern="#####0.00"/>"/>
				<span class="txt-rd">【※商品成本小数点1位数后无条件舍去】</span>
				</td>
	  </tr>
		<tr>
			<th>*厂商建议售价(市价)</th>			
				<td colspan="3"><input id="price" name="price" type="text" value="<fmt:formatNumber value="${proposeProduct.listPrice}" pattern="#####0.0"/>"/>
				<span class="txt-rd">【※广商建议售价小数点1位数后无条件舍去】</span>
				</td>
	  </tr>
	  <tr>
			<th>耀点价(会员价)</th>			
				<td colspan="3"><input id="proposeShelfPrice" name="proposeShelfPrice" type="text" value="<fmt:formatNumber value="${proposeProduct.prpsShelfPrice}" pattern="#####0.0"/>"/>
				<span class="txt-rd">【※耀点价(会员价)小数点1位数后无条件舍去】</span>
				</td>
		</tr>
		 <tr>
				<th>选择主档图显示类型</th>
		 		<td colspan="3">
					<input name="graphicType" type="radio" value="S" <c:if test="${proposeProduct.graphicType eq 'S'}">checked="checked"</c:if>/>方形图
			    <input name="graphicType" type="radio" value="R" <c:if test="${proposeProduct.graphicType eq 'R'}">checked="checked"</c:if>/>长形图
			  </td>
	  </tr>
		<tr>
			<th>税率类别(%)</th>			
				<td colspan="3"><input id="jTaxClass" name="tax" type="text" value="${proposeProduct.taxClass}"/>%【例:17%,请直接输入17】</td>
	  </tr>

		<tr>
			<th>前置时间</th>			
				<td colspan="3"><input id="jLeadTime" name="editleadtime" type="text" value="${proposeProduct.leadTime}"/></td>
	  </tr>

		<tr>
			<th>是否允许超收</th>			
		
				<td colspan="3"><input name="delivertolerance" type="radio" value="Y" <c:if test="${proposeProduct.isDeliverdTolerance eq 'Y'}">checked="checked"</c:if>/>是
                <input name="delivertolerance" type="radio" value="N" <c:if test="${proposeProduct.isDeliverdTolerance eq 'N'}">checked="checked"</c:if>/>否</td>
	  </tr>
		<tr>
			<th>商品体积</th>			
      <td colspan="3">
				     *长：<input type="text" name="length" id="length" value="${proposeProduct.length}"/>,
				     *宽:<input type="text" name="width" id="width" value="${proposeProduct.width}"/>,
				     *高：<input type="text" name="height" id="height" value="${proposeProduct.height}"/>
                【注:长宽高请输入整数】
	  		<br/>
            	*重量（g):<input type="text" name="weight" id="weight" value="${proposeProduct.weight}"/>,
            	*体积(cm3):<input type="text" name="volume" id="volume" value="${proposeProduct.volume}"/>
	  		<br/>
            	*销售单位(例如件, 个, 罐,...):<input type="text" name="unit" id="unit" value="${proposeProduct.unit}"/>
      </td>        
	  </tr>
		<tr>
			<th>最小／最大采购量</th>			
            	<td colspan="3">
                	最小采购量:<input type="text" name="minpo" id="minpo" value="${proposeProduct.minPoQuantity}"/>
                ,
                	最大采购量:<input type="text" name="maxpo" id="maxpo" value="${proposeProduct.maxPoQuantity}"/>
                </td>
	  		</tr>
		<tr>
			<th>物流运送温层类别</th>			
				<td colspan="3">
                	<input name="temperature" type="radio" value="1" <c:if test="${proposeProduct.temperatureType eq '0' or proposeProduct.temperatureType eq '1'}">checked="checked"</c:if>/>常溫
                    <input name="temperature" type="radio" value="2" <c:if test="${proposeProduct.temperatureType eq '2'}">checked="checked"</c:if>/>冷藏
                    <input name="temperature" type="radio" value="3" <c:if test="${proposeProduct.temperatureType eq '3'}">checked="checked"</c:if>/>冷冻
                    </td>
	  </tr>

		<tr>
			<th>退换货时是否需取回</th>			
				<td colspan="3">
                <input name="returnpickup" type="radio" value="Y" <c:if test="${proposeProduct.isReturnPickup eq 'Y'}">checked="checked"</c:if>/>是
                <input name="returnpickup" type="radio" value="N" <c:if test="${proposeProduct.isReturnPickup eq 'N'}">checked="checked"</c:if>/>否
                </td>
	  </tr>
	  <tr>
			<th>* 运送限定区域</th>			
				<td colspan="3">
				<s:select id="editDeliverGeoRange" name="editDeliverGeoRange" list="freightMenu.options" listKey="key"  listValue="value.name" headerKey="" headerValue="--请选择--"/>
                </td>
	  </tr>
	    <tr>
			<th>* 效期管理分类</th>			
				<td colspan="3">
				<s:select id="expireManage" name="expireManage" list="expireMenu.options" listKey="key"  listValue="value.name" headerKey="" headerValue="--请选择--"/>
                </td>
	  </tr>
		<tr>
			<th>此商品可否退换货</th>			
				<td colspan="3"><input name="returnable" type="radio" value="Y" <c:if test="${proposeProduct.isReturnable eq 'Y'}">checked="checked"</c:if>/>是
                <input name="returnable" type="radio" value="N" <c:if test="${proposeProduct.isReturnable eq 'N'}">checked="checked"</c:if>/>否</td>
	  </tr>
		<tr>
			<th>* 供应商</th>
			<td colspan="3">
				<s:textfield name="editsupplier" id="supplierIdParam" maxlength="6" readonly="readonly"/>
				<c-rt:if test="${proposeProduct.supplierId ne '010000' and proposeProduct.supplierId ne '010001'}">
				<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
							id="getSupplier"/>
				</c-rt:if>
				<input type="text" id="supplierCompanyName" value="${supplierCompanyName}" readonly="readonly" size="60" style="border: 0px;"/>
			</td>
		</tr>
		<tr id="twSupplier" style="display:none;">
			<th>* 台湾馆供应商</th>
			<td colspan="3">
				<s:textfield name="editTwSupplier" id="twSupplierIdParam"  maxlength="6" readonly="readonly"/>
				<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
							id="getTwSupplier"/>
				<input type="text" id="twSupplierCompanyName" value="${twSupplierCompanyName}" readonly="readonly" size="60" style="border: 0px;"/>
			</td>
		</tr>		 
		 <tr>
			<th>品牌</th> 			
     	<td colspan="3">
		     	<s:textfield name="editbrand" id="brandIdParam" />
			<img class="ui-icon ui-icon-search" src="/images/none.gif" style="height:16px; width:16px; position:relative; display:inline;" 
				id="getBrand"/>  
				<input type="text" name="brandName" id="brandName" value="${brandName}" readonly="readonly" size="60" style="border: 0px;"/>
			</td>
	 	 </tr>			  
		<tr>
			<th>* 主要负责PM</th>			
			<td colspan="3">
				<s:select id="pm" name="pm" list="users" listKey="username"  listValue="nameNative" headerKey="" headerValue="--请选择--"/>
			</td>
	  </tr>
 		<tr>
			<th>关键字</th>			
			<td colspan="3"><textarea name="keyword" cols="80" rows="5">${proposeProduct.productKeyword}</textarea></td>
	  </tr>
		<tr>
			<th>* 商品特色</th>			
			<td colspan="3">
				<textarea id="brief" name="brief" cols="60" rows="5">${brief}</textarea>
			</td>
	  </tr>
		<tr>
			<th>* 商品描述</th>			
			<td colspan="3">
				<textarea id="description" name="description" cols="150" rows="30">${description}</textarea>
				<script type="text/javascript">
				CKEDITOR.replace('description',{toolbar : 'product'});
				CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
	  </tr>
		<tr>
			<th>* 规格参数</th>			
			<td colspan="3">
				<textarea id="details" name="details" cols="150" rows="30" >${details}</textarea>
				<script type="text/javascript">
					CKEDITOR.replace('details',{toolbar : 'product'});
					CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
	  </tr>
		<tr>
			<th>购物须知<br/>（若不填会带入该馆预设内容）</th>
			<td colspan="3">
				<textarea id="orderNotice" name="orderNotice" cols="150" rows="30">${orderNotice}</textarea>
				<script type="text/javascript">
				CKEDITOR.replace('orderNotice',{toolbar : 'product'});
				CKEDITOR.config.contentsCss = '/css/yaodian100_pdpagese_v2.css';
				</script>
			</td>
		</tr>	  	  
			<tr>
				<td>
					<input type="hidden" id="spId" value=""/>
					<input type="hidden" id="spName" value=""/>
					<input type="hidden" id="isEndNode" name="isEndNode" value="${isEndNode}"/>
					<input type="hidden" id="tempCategoryPath" name="tempCategoryPath" value="${categoryPath}"/>
					<input type="hidden" id="mainCategoryId" name="mainCategoryId" value="${proposeProduct.proposeCategoryId}" />			
					<input type="hidden" name="productId" value="${productId}"/>
					<input type="submit" id="submit_button" name="submit" value="储存商品"/>
					<input type="button" onclick="this.form.action='list.do';this.form.submit();" value="Cancel"/>
				</td>
	  </tr>
</table>
</s:form> 
<div id="loadingImg" style="display:none;">
	<img src="/images/loading.gif"/>资料载入中,请稍候...
</div> 